<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/font-awesome.css" />
    <style>
        label {
            margin: 0.5rem;
            font-size: 1.2rem;
        }

        ul {
            margin-bottom: 0.5rem;
        }

        ul li {
            margin: 0.25rem 0.5rem;
            padding: 0.25rem;
            color: #000;
            word-wrap: break-word;
        }
    </style>
</head>

<body style="background-color:white" style="background-color:rgb(249,249,251)">
    <header class=" aui-bar-nav aui-bar-light" style="color:black;background-color:white;height:2.7rem;padding-top:0.8rem">
        <a class="aui-pull-left aui-btn">
            <i style="color:black" class="fa fa-arrow-left" aria-hidden="true" onclick="api.closeWin()"></i>
        </a>
        <div class="aui-title">修改密码</div>
        <a class="aui-pull-right">
            <span>
        <img src="../../image/header.png" style="padding-top:0.25rem">
      </span>
        </a>
    </header>


    <div class="aui-info aui-bar aui-padded-l-10 aui-padded-r-10 aui-bar-light" style="background-color:white;padding-top:2.0rem">
        <div>
            <i class="fa fa-download" aria-hidden="true" style="color:#B0B0B0;font-size:1rem;margin-left:0.7rem;margin-top:0.6rem;"></i>
            <span class="aui-margin-l-15" style="color:#B0B0B0"><input type="password" v-model="oldPassword" placeholder="请输入旧密码"></span>
        </div>
    </div>
    <div class="aui-info aui-bar aui-padded-l-10 aui-padded-r-10 aui-bar-light" style="background-color:white;padding-top:2.0rem">
        <div>
            <i class="fa fa-download" aria-hidden="true" style="color:#B0B0B0;font-size:1rem;margin-left:0.7rem;margin-top:0.6rem;"></i>
            <span class="aui-margin-l-15" style="color:#B0B0B0"><input type="password"  v-model="newPassword" placeholder="设置密码"></span>
        </div>
    </div>
    <div class="aui-info aui-bar aui-padded-l-10 aui-padded-r-10 aui-bar-light" style="background-color:white;padding-top:2.0rem;">
        <div>
            <i class="fa fa-download" aria-hidden="true" style="color:#B0B0B0;font-size:1rem;margin-left:0.7rem;margin-top:0.6rem;"></i>
            <span class="aui-margin-l-15" style="color:#B0B0B0"><input type="password"  v-model="againPassword" placeholder="确认密码"></span>
        </div>
    </div>
    <div style="margin:1rem auto;width:90%;">
        <p >
            <div @click="certain()" class="aui-btn aui-btn-primary aui-btn-block">确认</div>
        </p>
    </div>


</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue1.0.js"></script>
<script type="text/javascript" src="../../script/util.js"></script>
<script type="text/javascript">
    apiready = function() {
        new Vue({
                el: 'body',
                data: {
                    oldPassword: '',
                    newPassword: '',
                    againPassword: ''
                },
                methods: {
                    certain: function() {
                        var me = this;
                        api.confirm({
                            title: '提示',
                            msg: '你确定要更换密码吗',
                            buttons: ['确定', '取消']
                        }, function(ret, err) {
                            if (ret.buttonIndex == 1) {
                                me.change();
                            }
                        });
                    },
                    change: function() {
                        var me = this;
                        if (me.newPassword != "" || me.oldPassword != "") {
                            if (me.newPassword == me.againPassword) {
                                $api.post(serverIp + '/system/resetPasswordAppUser.do', {
                                    values: {
                                        oldPassword: me.oldPassword,
                                        newPassword: me.newPassword,
                                        againPassword: me.againPassword
                                    }
                                }, function(ret) {
                                    if (ret) {
                                        if (ret.success) {
                                            api.closeToWin({
                                                name: 'root'
                                            });
                                        } else {
                                            api.alert({
                                                title: '提示',
                                                msg: ret.msg,
                                            });
                                        }
                                    }
                                }, 'json');
                            } else {
                                alert("两次输入的新密码不一致");
                            }
                        } else {
                            api.alert({
                                title: '提示',
                                msg: '您尚未输入原密码或新密码',
                            });
                        }

                    }
                }
        });
    }
</script>
